<?php
/**
 * Created by PhpStrom
 * User: 郭碧云
 * Date: 2021/7/12 16:21
 * Desc:
 */

namespace App\Http\Validations\Admin;

use App\Service\CategoryService;
use Illuminate\Contracts\Validation\Validator;

class QuestionValidation {
    //验证更新添加数据
    public function checkData() {
        return [
            'rules' => [
                "type_id" => "required|min:1|integer",
                "question" => "required|filled",
                "level" => "required|min:1|integer",
                "category_id"=>"required|min:1|integer",
                "org_id" => "required|min:1|integer",
                "version_id" => "required|min:1|integer"
            ],
            'attributes' => [
                "type_id" => "题型",
                "question" => "题干",
                "level" => "等级",
                "category_id"=>"科目",
                "org_id" => "组织机构",
                "version_id" => "版本"
            ],
            'messages' => [
                "type_id" => "必须为正整数",
                "question" => "不能为空",
                "level" => "必须为正整数",
                "category_id" => "必须为正整数",
                "org_id" => "必须为正整数",
                "version_id" => "必须为正整数"
            ]
        ];
    }
    //验证id
    public function checkId(){
            return [
                'rules' => [
                    "id"=>"required|min:1|integer",
                ],
                'attributes' => [
                    "id"=>"编号",
                ],
                'messages' => [
                    "id"=>"必须是正整数",
                ]
            ];
    }
    //验证标签
    public function checkTagID(){
        return [
            'rules' => [
                "tag_id"=>"required|min:1|integer",
            ],
            'attributes' => [
                "tag_id"=>"标签",
            ],
            'messages' => [
                "tag_id.required"=>"必须是正整数",
            ]
        ];
    }
    //验证删除数组
    public function checkIDS(){
        return [
            "rules"=>[
                'ids.*' => "required|min:1|integer",
            ],
        ];
    }
    //验证后添加的钩子函数
    public function customValidate(Validator $validator) {
        //
    }
}
